# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Daniel Nagy <danielnagy at gmx de>
# Contributor: Daniel Micay <danielmicay@gmail.com>

pkgname=haskell-aeson
_hkgname=aeson
pkgver=2.1.2.0
pkgrel=8
pkgdesc="A JSON parsing and encoding library optimized for ease of use and high performance"
url="https://github.com/haskell/aeson"
license=("GPL")
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-onetuple' 'haskell-quickcheck' 'haskell-attoparsec'
         'haskell-base-compat-batteries' 'haskell-data-fix' 'haskell-dlist' 'haskell-generically'
         'haskell-hashable' 'haskell-indexed-traversable' 'haskell-primitive' 'haskell-scientific'
         'haskell-semialign' 'haskell-strict' 'haskell-tagged' 'haskell-text-short'
         'haskell-th-abstraction' 'haskell-these' 'haskell-time-compat'
         'haskell-unordered-containers' 'haskell-uuid-types' 'haskell-vector' 'haskell-witherable')
makedepends=('ghc' 'haskell-diff' 'haskell-base-compat' 'haskell-base-orphans'
             'haskell-base16-bytestring' 'haskell-generic-deriving' 'haskell-integer-logarithms'
             'haskell-quickcheck-instances' 'haskell-tasty' 'haskell-tasty-golden'
             'haskell-tasty-hunit' 'haskell-tasty-quickcheck')
source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-${pkgver}.tar.gz")
sha512sums=('531e5734f6d72d185a1da4c8c2fcf71d88cbb5178bda11ffec2f90f2acef17bfed64bd894023c97e5a73aa0fae13d73be09cbb44dcd5762926bc46b556283363')

build() {
  cd $_hkgname-$pkgver
  runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
            -f-cffi -fordered-keymap
  runhaskell Setup build $MAKEFLAGS
  runhaskell Setup register --gen-script
  runhaskell Setup unregister --gen-script
  sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
  sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
  cd $_hkgname-$pkgver
  runhaskell Setup test --show-details=direct
}

package() {
  cd $_hkgname-$pkgver

  install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
  install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
  runhaskell Setup copy --destdir="$pkgdir"
  rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
